<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Archiver() {
            // 在这里补充代码
            let val = null;
            this.historyArr = [];
            Object.defineProperty(this, "val", {
                get() {
                    return val;
                },
                set(str) {
                    val = str;
                    this.historyArr.push({
                        val: str
                    });
                }
            })
        }

        Archiver.prototype.getArchive = function () {
            console.log(this.historyArr);
        }

        var arc = new Archiver();
        console.log(arc.val); // null​

        arc.val = 11;
        console.log(arc.val); // 11​

        arc.val = 13;
        console.log(arc.val); // 13​

        arc.val = 21;
        console.log(arc.val); // 21​

        arc.val = 33;
        console.log(arc.val); // 33

        arc.getArchive(); // [{ val: 11 }, { val: 13 }, {val: 21}]
    </script>
</body>

</html>